<?php
if(!isset($_POST['key'])||$_POST['key']==''){
	$jsonRecordArray['STATUS'] = 'EXCEPTION';
}else{
	$uid = $_POST['key'];
	
	if($_POST['val']!=''){
		$sqlCondition = ' AND `address` LIKE "'.$_POST['val'].'%" ';
	}
	
	$sql = 'SELECT `address` FROM `'.ESYPARK_SEARCH_COOKIES.'` WHERE `devid` ="'.$uid.'" '.$sqlCondition.' ORDER BY `times` DESC,`vid` DESC LIMIT 0,6';
	//errorEventLog::displaysSQLPhase($sql,PROGRAM_DEBUG);
	$tRecordSet = $dbObj -> executeQuery($sql);
	
	if($tRecordSet){
		$i = 0;
		foreach ($tRecordSet as $val)
		{
			$jsonRecordArray['PARKER'][$i]['WORD'] = $val['ADDRESS'];
			$i++;
		}
		$jsonRecordArray['STATUS'] = 'OK';
	}else{
		$jsonRecordArray['STATUS'] = 'ZERO_RESULTS';
	}
}

if(is_array($jsonRecordArray)){
	echo json_encode($jsonRecordArray);
}